package com.aysafety.ayelevator.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import com.anyi.safe.communication.model.ElevatorAccident;
import com.anyi.safe.communication.model.ElevatorData;

@Component
public class DataListener extends com.anyi.safe.communication.sdk.DataListener {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    ElevatorRealTimeListener elevatorRealTimeListener;

    public DataListener() {

    }

    @Async
    public void onReadData(ElevatorData elevatorData) {
        elevatorRealTimeListener.start(elevatorData, null);
        logger.info("ReadData正常接收到数据");
    }

    @Async
    public void onAlarmData(ElevatorAccident elevatorAccident) {
        elevatorRealTimeListener.start(elevatorAccident.getElevatorData(), elevatorAccident);
        logger.info("AlarmData正常接收到数据");
    }

    @Async
    public void onCannelAlarm(String s, String s1) {
        logger.info("onCannelAlarm");
        logger.info(s);
        logger.info(s1);
    }
}
